<template>
  <div class="back-message">
    <div class="back-message-upload" v-for="(item, index) in list" :key="index">
      <div class="back-left">
        <div
          class="el-icon-circle-close left-close"
          @click="deleteBackMessage(index)"
        ></div>
        <el-input
          v-model="item.content"
          placeholder="请输入备注信息"
        ></el-input>
      </div>
      <div class="back-right">
        <tea-upload
          :editList.sync="item.exTeaImgList"
          :keyId.sync="item.exKeyId"
        />
      </div>
    </div>
    <el-button icon="el-icon-plus" circle @click="addBackMessage"></el-button>
  </div>
</template>

<script>
import TeaUpload from "@/components/common/back-message-upload.vue";
export default {
  components: {
    TeaUpload,
  },
  props: {
    list: Array,
  },
  data() {
    return {};
  },
  methods: {
    addBackMessage() {
      const { list } = this;
      list.push({
        content: "",
        exKeyId: 0,
      });
      this.$emit("update:list", list);
    },
    deleteBackMessage(index) {
      // 删除的起始位置与删除长度
      const { list } = this;
      list.splice(index, 1);
      this.$emit("update:list", list);
    },
  },
};
</script>

<style lang="scss" scoped>
.back-message-upload {
  display: flex;
  align-items: center;
  margin-bottom: 30px;
  .back-left {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 200px;
    margin-right: 30px;
    .left-close {
      font-size: 20px;
      color: red;
      margin-right: 10px;
      cursor: pointer;
    }
  }
}
</style>
